package nii.game.mobileserio.action_game;

import nii.game.mobileserio.class_static.ControlStatic;
import nii.game.mobileserio.dialog.DialogViewScore;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;

public class Option extends Activity implements OnClickListener{
	
	//==========================|| onCreate Function ||================================//
	
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		setContentView(R.layout.optiongame);
		
		// Checkbox Sound
		final CheckBox ch_Sound = (CheckBox)findViewById(R.id.checkbox_sound);
		ch_Sound.setChecked(true);
		if (ch_Sound.isChecked()==true)
			ControlStatic.SOUND = true;
		else
			ControlStatic.SOUND = false;
		
		//================|| touch Checkbox Sound event ||==============//
		
		ch_Sound.setOnClickListener(new View.OnClickListener() 
		{
			public void onClick(View arg0) {
				if (((CheckBox) arg0).isChecked()){
					ControlStatic.SOUND = true;
				}
				else
					ControlStatic.SOUND = false;
			}
		});
		
		// Checkbox Music
		final CheckBox ch_Music = (CheckBox)findViewById(R.id.checkbox_music);
		ch_Music.setChecked(true);
		if (ch_Music.isChecked()==true)
			ControlStatic.MUSIC = true;
		else
			
			ControlStatic.MUSIC = false;
		
		//================|| touch Checkbox Music event ||==============//
		
		ch_Music.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
				if (((CheckBox) arg0).isChecked()){
					ControlStatic.MUSIC = true;
				}
				else
					ControlStatic.MUSIC = false;
				
			}
		});
		
		// Button Đóng
		Button button_close = (Button)findViewById(R.id.dong_option);
		button_close.setOnClickListener(new View.OnClickListener() {			
			public void onClick(View arg0) {
				Intent i = new Intent(Option.this, MenuActivity.class);
				Option.this.startActivity(i);
				Option.this.finish();			
			}
		});
		
		// Button DiemCao
		Button button_diemcao = (Button)findViewById(R.id.btn_diemcao);
		button_diemcao.setOnClickListener(new View.OnClickListener() {			
			public void onClick(View arg0) {
				DialogViewScore xemdiem = new DialogViewScore(Option.this);
				xemdiem.show();
			}
		});
		 
		
	}
	
	//==================================|| onCLick Function ||=====================================//
	
	public void onClick(View v) {
	}
	
	
	//=================================|| onKeyDown Function ||===================================//
	
	public boolean onKeyDown(int keycode, KeyEvent event)
	{
		// nút Back của điện thoại
		if(keycode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN)
		{
			Intent i = new Intent(Option.this, MenuActivity.class);
			Option.this.startActivity(i);
			Option.this.finish();
		}
		return false;
	}
	
	
}
